home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / PMDLL.LIB < prev    next >
Text File  |  1993-12-11  |  7KB  |  143 lines

  1. /*****************************************************************************
  2.  *** PMdll.lib - This library contains wrappers functions and definitions  ***
  3.  ***             used in making calls into the Presentation Manager        ***
  4.  ***             DLLs.  This file may be #include'ed into your source      ***
  5.  ***             file, or you may want to improve speed and memory use by  ***
  6.  ***             copying just the relevant sections into your source code. ***             ***
  7.  *****************************************************************************/
  8.  
  9. #define  _PMDLL_LIB  1
  10.  
  11. WinCreateObject(ClassName,Title,SetupString,Location,Flags)
  12. {
  13.    // WinCreateObject: Create an instance of an object class
  14.    //  ClassName: A string which contains the name of the class of which this object is a member.
  15.    //  Title: A string which contains the initial title of the object as it is to appear
  16.    //         when displayed on the user interface underneath an icon or on
  17.    //         the title bar of an open object.
  18.    //  SetupString: A series of "keyname=value" pairs separated by commas, that change the behavior of the object.
  19.    //               Each object class documents its keynames and the parameters parameters it expects to see immediately following.
  20.    //               Note that ALL parameters have safe defaults, so it is never necessary to pass
  21.    //               unnecessary parameters to an object.
  22.    //  Location: Folder location.  This can be the real folder path name or one of these:
  23.    //            <WP_NOWHERE>, <WP_DESKTOP>, <WP_OS2SYS>, <WP_TEMPS>, <WP_CONFIG>, <WP_START>, <WP_INFO>, <WP_DRIVES>
  24.    //  Flags: Creation flags:
  25.          #define CO_FAILIFEXISTS     0
  26.          #define CO_REPLACEIFEXISTS  1
  27.          #define CO_UPDATEIFEXISTS   2
  28.    //  Return: returns handle for object, which is NULL (0) for error, else
  29.    //          handle can be used for further calls for this object
  30.    #define ORD_WINCREATEOBJECT   281
  31.    return PMDynamicLink("PMWP",ORD_WINCREATEOBJECT,BIT32,CDECL,
  32.                         ClassName,Title,SetupString,Location,Flags)
  33. }
  34.  
  35. WinQueryObject(ObjectID)
  36. {
  37.    // WinQueryObject: Return a handle to the persistent ObjectID
  38.    //  ObjectID: The ObjectID of an existing object, for example "<WP_DESKTOP>", or
  39.    //            alternatively the fully qualified filename of any file or directory. 
  40.    //  Return: NULL for error, else return a handle to the object created.
  41.    //          This handle is persistent and can be used for the WinSetObjectData
  42.    //          and WinDestroyObject function calls. 
  43.    #define ORD_WINQUERYOBJECT    252
  44.    return PMDynamicLink("PMWP",ORD_WINQUERYOBJECT,BIT32,CDECL,ObjectID);
  45. }
  46.  
  47. WinSetObjectData(WPObjectHandle,SetupString)
  48.    // set parameters in SetupString for WPObjectHandle, which is like the value
  49.    // returned by WinCreateObject.
  50.    // Return TRUE for success and FALSE for error.
  51. {
  52.    #define ORD_WINSETOBJECTDATA  250
  53.    return PMDynamicLink("PMWP",ORD_WINSETOBJECTDATA,BIT32,CDECL,WPObjectHandle,SetupString)
  54. }
  55.  
  56. WinSwitchToProgram(SwitchHandle)
  57. {
  58.    // Switch to this handle, where SwitchHandle is an entry entry handle in the window list.
  59.    // Returns 0 for success or one of the following errors:
  60.       #define INV_SWITCH_LIST_ENTRY_HANDLE     4610  // Invalid Window List entry handle of the program to be activated.
  61.       // #define NOT_PERMITTED_TO_CAUSE_SWITCH ????  // Requesting program is not the current foreground process.
  62.    #define ORD_WIN32SWITCHTOPROGRAM    131
  63.    return PMDynamicLink("PMSHAPI",ORD_WIN32SWITCHTOPROGRAM,BIT32,CDECL,SwitchHandle);
  64.  
  65. }
  66.  
  67. WinQuerySwitchHandle(WindowHandle,ProcessID)
  68. {
  69.    #define ORD_WIN32QUERYSWITCHHANDLE  125
  70.    return PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHHANDLE,BIT32,CDECL,
  71.                         WindowHandle,ProcessID);
  72. }
  73.  
  74. WinQuerySwitchList(AnchorBlock)
  75.    // return an array of switch list handles.  Number can be determined by
  76.    // the size of the array returned, which will be NULL for an error.
  77. {
  78.    #define FIRST_SWENTRY_OFFSET 4 // offset in returned block of first entry
  79.    #define SWENTRY_SIZE 100       // size of each entry in entry array
  80.    #define ORD_WIN32QUERYSWITCHLIST 126
  81.    // determine how big the blob must be to hold the data received and then
  82.    // allocate it much bigger just to be sure
  83.    _WQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,AnchorBlock,NULL,0);
  84.    if ( _WQCount == 0 )
  85.       return NULL;
  86.    // create big big big extrabig BLOb to hold received data
  87.    _WinSizeNeeded = (_WQCount * SWENTRY_SIZE) + FIRST_SWENTRY_OFFSET;
  88.    BLObSize(_WQblob,_WinSizeNeeded*2);
  89.    // once again, query for list of WinSwitches
  90.    _WQCount = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHLIST,BIT32,CDECL,
  91.                             AnchorBlock,_WQblob,_WinSizeNeeded * 3 / 2);
  92.    if ( _WQCount == 0 )
  93.       return NULL;
  94.    // create array for _WQCount entries to hold the Switch entries
  95.  
  96.    for ( i = 0, _WEoffset = FIRST_SWENTRY_OFFSET; i < _WQCount; i++, _WEOffset += SWENTRY_SIZE )
  97.       _SWEntry[i] = BLObGet(_WQblob,_WEoffset,UWORD32);
  98.    // finished, and so return this array
  99.    return _SWEntry;
  100. }
  101.  
  102. WinQuerySwitchEntry(SwitchListHandle,SwitchControlData)
  103.    // Query based on this SwitchListHandle for SwitchControl Data.  Return 0 for
  104.    // success else error.  Set SwitchControlData to structure with the following
  105.    // structure members (all integers except for title):
  106.    //  hwnd:      Window Handle
  107.    //  hwndIcon:  Icon handle
  108.    //  program:  Program handle
  109.    //  process:   Process ID
  110.    //  session:   Session ID
  111.    //  visibility:  ???
  112.    //  jump:        ???
  113.    //  title:     title of this window; string
  114.    //  ProgType:  program type
  115.  {
  116.    // create blob to hold all the data
  117.    BLObSize(_SwEntry,SWENTRY_SIZE);
  118.    #define ORD_WIN32QUERYSWITCHENTRY         124
  119.    _result = PMDynamicLink("PMSHAPI",ORD_WIN32QUERYSWITCHENTRY,BIT32,CDECL,SwitchListHandle,_SwEntry);
  120.    if ( _result == 0 ) {
  121.       // place each field in SwitchControlData structure
  122.       undefine(SwitchControlData);
  123.       SwitchControlData.hwnd = BLObGet(_SwEntry,_offset=0,UWORD32);
  124.       SwitchControlData.hwndIcon = BLObGet(_SwEntry,_offset+=4,UWORD32);
  125.       SwitchControlData.program = BLObGet(_SwEntry,_offset+=4,UWORD32);
  126.       SwitchControlData.process = BLObGet(_SwEntry,_offset+=4,UWORD32);
  127.       SwitchControlData.session = BLObGet(_SwEntry,_offset+=4,UWORD32);
  128.       SwitchControlData.visibility = BLObGet(_SwEntry,_offset+=4,UWORD32);
  129.       SwitchControlData.jump = BLObGet(_SwEntry,_offset+=4,UWORD32);
  130.       strcpy(SwitchControlData.title,BLObGet(_SwEntry,_offset+=4,68));
  131.       SwitchControlData.ProgType = BLObGet(_SwEntry,_offset+=68,UWORD32);
  132.    }
  133.    return _result;
  134. }
  135.  
  136. PostMessage(WindowHandle,MessageID,Param1,Param2)
  137. {
  138.    #define ORD_WIN32POSTMSG   919
  139.    return PMDynamicLink("PMWIN",ORD_WIN32POSTMSG,BIT32,CDECL,
  140.                         WindowHandle,MessageID,Param1,Param2);
  141. }
  142.  
  143.